<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>软件园商城</title>
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/signin.css" rel="stylesheet">
  <style>
    /* 验证码图片边框 */
    img[src^="/captcha"] {
      border: 1px solid #ddd;
      border-radius: 4px;
      padding: 2px;
    }

    /* 输入框对齐 */
    .form-group.row {
      margin-bottom: 15px;
      align-items: center;
    }
  </style>
</head>

<body class="text-center">
<form class="form-signin" action="#" th:action="@{/dologin}" method="post">
  <img class="mb-4" src="img/bootstrap-solid.svg" alt="" width="72" height="72">
  <h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
  <p style="color:red" th:text="${msg}"></p>

  <label class="sr-only">用户名</label>
  <input type="text" name="name" class="form-control" placeholder="Username" required="" autofocus="">
  <label class="sr-only">密码</label>
  <input type="password" name="password" class="form-control" placeholder="Password" required="">
  <!-- 新增验证码输入区域 -->
  <div class="form-group row">
    <div class="col-8">
      <input type="text" name="code" class="form-control"
             placeholder="验证码" required>
    </div>
    <div class="col-4">
      <img src="/captcha"
           onclick="this.src='/captcha?t='+new Date().getTime()"
           style="cursor:pointer; height:38px;"
           title="点击刷新验证码">
    </div>
  </div>
  <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button><br>
  <span><a href="#" th:href="@{/ToRegister}">没有账号？立即注册</a> </span>
  <p class="mt-5 mb-3 text-muted">© 2018-2020</p>
</form>
<script>
  window.onload = function() {
    if(performance.navigation.type === 2) { // 检测是否通过后退按钮进入
      location.replace("/Login"); // 替换历史记录
    }
  };

</script>
</body>

</html>